from fastapi import FastAPI, Response

app = FastAPI()


@app.get("/")
def https_index(response: Response):
    # 启用HSTS（取消注释即可测试HSTS机制）
    response.headers["Strict-Transport-Security"] = "max-age=3600; includeSubDomains"
    return {"message": "This is an HTTPS page (signed with valid certificate)"}


# 运行命令（需替换证书路径）：
# uvicorn https_server:app --host 0.0.0.0 --port 8443 --ssl-keyfile server_key.pem --ssl-certfile server_cert.pem
